package com.supermarket.api.repository;

import com.supermarket.api.entity.ProductEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 商品相关
 * @author 李其伟
 * @date 2023/10/19
 */
@Repository
public interface ProductRepository extends JpaRepository<ProductEntity, Long> {

    Page<ProductEntity> findAllByPublishStatus(Integer publishStatus, Pageable pageable);

    Page<ProductEntity> findAllByCategoryIdAndPublishStatus(Long categoryId, Integer publishStatus, Pageable pageable);

    Page<ProductEntity> findAllByShopId(Long shopId, Pageable pageable);

    ProductEntity findAllBySku(String sku);

    List<ProductEntity> findAllBySkuIn(List<String> sku);
}
